/*=========================================================================

Program:   Virtual Surgery
Language:  C++
Date:      2009-9-1
Version:   0.1
Mail:		   nelfylee@gmail.com

Copyright (c) 2009 Nelfy Lee. All rights reserved.

=========================================================================*/
#ifndef _DISPLAY_FRAMEWORK_H_
#define _DISPLAY_FRAMEWORK_H_

#include <QFrame>
#include <QModelIndex>

#include "Source.h"

class Source;
class View2D;
class View3D;
class PipelineModel;
class QSplitter;
class QStandardItem;



// currently, id will not change, so just use 1,2,3,4 to represent 4-views
class DisplayFramework : public QFrame
{
	Q_OBJECT
public:
	DisplayFramework(QWidget *parent);
	~DisplayFramework(){}

	void setPipeline(PipelineModel *pipeline);
	void resetLayout();
	void initViews();

	View2D* getActive2DView();
	View3D* getActive3DView();
	View2D* get2DView(const QModelIndex&);
	View3D* get3DView(const QModelIndex&);

public slots:
	void slotMaximizeView(int id);
	void slotRestoreView(int id);
	void slotSourceSelected(const QModelIndex&);

	// switch to real time slicing mode
	void slotStartRealTimeSlicing(Source*);
	void slotStopRealTimeSlicing();
	void slotUpdateSlicing();

	void slotLink3DViewCameras(bool flag);

private slots:
	void slotSourcePreRemove(const QModelIndex&);
	void slotSetBase(const QModelIndex& index);
	void slotActiveView(int);

signals:
	void emitViewMaximized(int id);
	void emitSeedPicked();
	void emitViewActivated(int id);
	void emitStartCutting();
	void emitStopCutting();
	void emitDoCut();

private:
	void saveViewLayout();
	void clearViews(){}


private:
	QSplitter *m_splitter2DViews;
	QSplitter *m_splitter3DViews;
	QSplitter *m_splitterVertical;

	View2D *m_2dViewLeft;
	View2D *m_2dViewRight;
	View3D *m_3dViewLeft;
	View3D *m_3dViewRight;

	View3D *m_realTimeSlicingView;

	QList<int> origsizeUP;
	QList<int> m_splitterSizes2D;
	QList<int> m_splitterSizes3D;
	QList<int> m_splitterSizesVer;

	bool m_isViewMaximized;	//
	bool m_isRealTimeSlicing;

	PipelineModel *m_pipeline;

	QModelIndex m_lastIndex;
	Source *m_baseSource;
};


#endif

